package com.zdsoft.blp.zongbuju;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Handler;
import android.os.Message;

import com.zdsoft.blp.R;
import com.zdsoft.blp.gongyong.net.BaseActivity;

/**
 * Created by pc on 2016/9/5.
 */
public class GuanGaoActivity extends BaseActivity {
    private SharedPreferences sp;
    @Override
    protected void init() {
        setContentView(R.layout.guanggaolayout);

        new Thread(){
            @Override
            public void run() {
                super.run();
                try {
                    sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                Message msg = handler.obtainMessage();
                msg.what=1;
                handler.sendMessage(msg);
            }
        }.start();
    }

    private Handler handler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            if(msg.what==1){
                sp = getSharedPreferences("info", Context.MODE_PRIVATE);
                if(sp.getBoolean("isFirst",true)){
                    Intent intent = new Intent(GuanGaoActivity.this,FirstOpenActivity.class);
                    startActivity(intent);
                }else {
                    Intent intent = new Intent(GuanGaoActivity.this,MainActivity.class);
                    startActivity(intent);
                }
                GuanGaoActivity.this.finish();
            }
        }
    };

    @Override
    protected void onPause() {
        super.onPause();
        SharedPreferences.Editor editor = sp.edit();
        editor.putBoolean("isFirst",false);
        editor.commit();
    }

}
